import logging
from logging.handlers import TimedRotatingFileHandler
from role_config import role, slave_id, queen_identifier


log_file_path = 'test.log'
logger = None


def logger_factory():
    global logger
    if logger is None:
        handler = TimedRotatingFileHandler(log_file_path, when='midnight', interval=1, backupCount=90)
        formatter = logging.Formatter('%(asctime)s - %(filename)s - %(levelname)s -%(message)s')
        handler.setFormatter(formatter)
        logger = logging.getLogger()
        logger.setLevel(logging.INFO)
        logger.addHandler(handler)
    return logger
